#include "Comment.hpp"


int main(int argc,char*argv[])
{
    if(argc!=3)
    {
        cout<<"Serveip Serveport"<<endl;
    }
    cout<<"客户端启动成功"<<endl;
    //创建套接字
    int sockfd=socket(AF_INET,SOCK_STREAM,0);
    if(sockfd<0) cout<<"create sockfd err\n";
    //进行数据填充
    struct sockaddr_in tmp;
    bzero(&tmp,sizeof(tmp));
    tmp.sin_family=AF_INET;
    tmp.sin_port=htons(stoi(argv[2]));
    tmp.sin_addr.s_addr=inet_addr(argv[1]);
    //和服务器进行connect
    int n=connect(sockfd,(struct sockaddr*)&tmp,sizeof(tmp));
    if(n<0)cout<<"connect err\n";
    while(true)
    {
        string message;
        getline(cin,message);
        write(sockfd,message.c_str(),sizeof(message));
    }
    return 0;
}